package empacotador;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class FileManager {
	FileManager(String filePath) throws IOException
	{
		data = new DataInputStream(
		           new BufferedInputStream(
		               new FileInputStream(filePath)));
		
		file = new File(filePath);
		data.mark(0);
	}	
	
	public byte[] ler_bytes(int nBytes, int offset) throws IOException
	{
		data.skip(offset);
		byte[] buffer = new byte[nBytes];
		data.read(buffer,0,nBytes);
		
		/* Resetar o ponteiro? */
		data.reset();
		
		return buffer;
		
	}
	
	public long tamanho()
	{
		return file.length();
	}
	
	public String nome()
	{
		return file.getName();
	}
	
	private DataInputStream data;
	private File file;
}
